package Servlet;

import Bean.Page;
import Service.RegisterService;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 张
 * Date: 2025-03-09
 * Time: 19:21
 */
//获取用户注册申请表
@WebServlet("/RegisterListServlet")
public class RegisterListServlet extends HttpServlet {
    private RegisterService registerService = new RegisterService();

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        resp.setContentType("application/json;charset=utf8");
        int pageNo = Integer.parseInt(req.getParameter("pageNo"));
        //约定每页查询5条数据
        int pageSize = 5;
        Page page = registerService.select(pageNo,pageSize);
//        if(page.getList() == null || page.getList().size() == 0) {
//            req.setAttribute("status", "error");
//            req.setAttribute("message", "申请表暂无数据");
//            req.setAttribute("redirectUrl", "admin_index.jsp");
//            req.setAttribute("waitSeconds", 2);
//            req.getRequestDispatcher("skip.jsp").forward(req,resp);
//        }
        req.setAttribute("list",page.getList());
        req.setAttribute("box",page);
        req.getRequestDispatcher("register_list.jsp").forward(req,resp);
    }
}
